.class public Lcom/burstly/lib/util/json/JsonProcessorFactory;
.super Ljava/lang/Object;
.source "JsonProcessorFactory.java"


# static fields
.field private static final CONFIGURATION:Ljava/util/Map; = null
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Map",
            "<",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field

.field private static final JACKSON_CLASSPATH:Ljava/lang/String; = "com.burstly.jackson.map.ObjectMapper"

.field private static final JSON_PROCESSOR_CLASSNAME_TEMPLATE:Ljava/lang/String; = "com.burstly.lib.util.json.%@Processor"

.field private static final LOG:Lcom/burstly/lib/util/LoggerExt; = null

.field private static final TAG:Ljava/lang/String; = "JsonProcessorFactory"

.field private static sCurrentJsonProcessor:Lcom/burstly/lib/util/json/IJsonProcessor;


# direct methods
.method static constructor <clinit>()V
    .locals 3

    .prologue
    .line 40
    invoke-static {}, Lcom/burstly/lib/util/LoggerExt;->getInstance()Lcom/burstly/lib/util/LoggerExt;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/util/json/JsonProcessorFactory;->LOG:Lcom/burstly/lib/util/LoggerExt;

    .line 45
    new-instance v0, Ljava/util/LinkedHashMap;

    invoke-direct {v0}, Ljava/util/LinkedHashMap;-><init>()V

    sput-object v0, Lcom/burstly/lib/util/json/JsonProcessorFactory;->CONFIGURATION:Ljava/util/Map;

    .line 69
    sget-object v0, Lcom/burstly/lib/util/json/JsonProcessorFactory;->CONFIGURATION:Ljava/util/Map;

    const-string v1, "com.burstly.jackson.map.ObjectMapper"

    const-string v2, "Jackson"

    invoke-interface {v0, v1, v2}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 70
    return-void
.end method

.method private constructor <init>()V
    .locals 0

    .prologue
    .line 75
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 76
    return-void
.end method

.method public static declared-synchronized getCurrentJsonProcessor()Lcom/burstly/lib/util/json/IJsonProcessor;
    .locals 12

    .prologue
    .line 80
    const-class v6, Lcom/burstly/lib/util/json/JsonProcessorFactory;

    monitor-enter v6

    :try_start_0
    sget-object v5, Lcom/burstly/lib/util/json/JsonProcessorFactory;->sCurrentJsonProcessor:Lcom/burstly/lib/util/json/IJsonProcessor;

    if-eqz v5, :cond_0

    .line 81
    sget-object v5, Lcom/burstly/lib/util/json/JsonProcessorFactory;->sCurrentJsonProcessor:Lcom/burstly/lib/util/json/IJsonProcessor;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 92
    .local v0, clz:Ljava/lang/Class;,"Ljava/lang/Class<+Lcom/burstly/lib/util/json/IJsonProcessor;>;"
    .local v2, entry:Ljava/util/Map$Entry;,"Ljava/util/Map$Entry<Ljava/lang/String;Ljava/lang/String;>;"
    .local v3, fullClassName:Ljava/lang/String;
    .local v4, i$:Ljava/util/Iterator;
    :goto_0
    monitor-exit v6

    return-object v5

    .line 84
    .end local v0           #clz:Ljava/lang/Class;,"Ljava/lang/Class<+Lcom/burstly/lib/util/json/IJsonProcessor;>;"
    .end local v2           #entry:Ljava/util/Map$Entry;,"Ljava/util/Map$Entry<Ljava/lang/String;Ljava/lang/String;>;"
    .end local v3           #fullClassName:Ljava/lang/String;
    .end local v4           #i$:Ljava/util/Iterator;
    :cond_0
    :try_start_1
    sget-object v5, Lcom/burstly/lib/util/json/JsonProcessorFactory;->CONFIGURATION:Ljava/util/Map;

    invoke-interface {v5}, Ljava/util/Map;->entrySet()Ljava/util/Set;

    move-result-object v5

    invoke-interface {v5}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v4

    .restart local v4       #i$:Ljava/util/Iterator;
    :cond_1
    :goto_1
    invoke-interface {v4}, Ljava/util/Iterator;->hasNext()Z

    move-result v5

    if-eqz v5, :cond_2

    invoke-interface {v4}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/util/Map$Entry;

    .line 85
    .restart local v2       #entry:Ljava/util/Map$Entry;,"Ljava/util/Map$Entry<Ljava/lang/String;Ljava/lang/String;>;"
    invoke-interface {v2}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Ljava/lang/String;

    const-string v7, "JsonProcessorFactory"

    invoke-static {v5, v7}, Lcom/burstly/lib/util/Utils;->isSdkAvailable(Ljava/lang/String;Ljava/lang/String;)Z
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    move-result v5

    if-eqz v5, :cond_1

    .line 87
    :try_start_2
    const-string v7, "com.burstly.lib.util.json.%@Processor"

    const-string v8, "%@"

    invoke-interface {v2}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Ljava/lang/CharSequence;

    invoke-virtual {v7, v8, v5}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;

    move-result-object v3

    .line 88
    .restart local v3       #fullClassName:Ljava/lang/String;
    invoke-static {v3}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class;

    move-result-object v0

    .line 90
    .restart local v0       #clz:Ljava/lang/Class;,"Ljava/lang/Class<+Lcom/burstly/lib/util/json/IJsonProcessor;>;"
    invoke-virtual {v0}, Ljava/lang/Class;->newInstance()Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Lcom/burstly/lib/util/json/IJsonProcessor;

    sput-object v5, Lcom/burstly/lib/util/json/JsonProcessorFactory;->sCurrentJsonProcessor:Lcom/burstly/lib/util/json/IJsonProcessor;

    .line 91
    sget-object v5, Lcom/burstly/lib/util/json/JsonProcessorFactory;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v7, "JsonProcessorFactory"

    const-string v8, "JSON Processor successfully instantiated for the {0} library"

    const/4 v9, 0x1

    new-array v9, v9, [Ljava/lang/Object;

    const/4 v10, 0x0

    invoke-interface {v2}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;

    move-result-object v11

    aput-object v11, v9, v10

    invoke-virtual {v5, v7, v8, v9}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 92
    sget-object v5, Lcom/burstly/lib/util/json/JsonProcessorFactory;->sCurrentJsonProcessor:Lcom/burstly/lib/util/json/IJsonProcessor;
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_0

    goto :goto_0

    .line 94
    .end local v0           #clz:Ljava/lang/Class;,"Ljava/lang/Class<+Lcom/burstly/lib/util/json/IJsonProcessor;>;"
    .end local v3           #fullClassName:Ljava/lang/String;
    :catch_0
    move-exception v1

    .line 95
    .local v1, e:Ljava/lang/Exception;
    :try_start_3
    sget-object v5, Lcom/burstly/lib/util/json/JsonProcessorFactory;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v7, "JsonProcessorFactory"

    invoke-virtual {v5, v7, v1}, Lcom/burstly/lib/util/LoggerExt;->logThrowable(Ljava/lang/String;Ljava/lang/Throwable;)V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    goto :goto_1

    .line 80
    .end local v1           #e:Ljava/lang/Exception;
    .end local v2           #entry:Ljava/util/Map$Entry;,"Ljava/util/Map$Entry<Ljava/lang/String;Ljava/lang/String;>;"
    :catchall_0
    move-exception v5

    monitor-exit v6

    throw v5

    .line 99
    :cond_2
    :try_start_4
    new-instance v5, Ljava/lang/RuntimeException;

    const-string v7, "No JSON libraries available."

    invoke-direct {v5, v7}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    throw v5
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_0
.end method
